home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15681 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: prairienet.org!wemccaug
  2. From: wemccaug@prairienet.org (Wendy E. McCaughrin)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How to pass function as arg?
  5. Date: 21 Apr 1996 03:37:11 GMT
  6. Organization: University of Illinois at Urbana
  7. Message-ID: <4lcah7$fhj@vixen.cso.uiuc.edu>
  8. References: <317937f7.325108@news.csus.edu>
  9. Reply-To: wemccaug@prairienet.org (Wendy E. McCaughrin)
  10. NNTP-Posting-Host: firefly.prairienet.org
  11.  
  12.  
  13. In a previous article, wleong@sfsu.edu (Jerry Leong) says:
  14.  
  15. >Please don't flame me for asking this question as I have read the faq,
  16. >the newsgroup & I still couldn't find a satisfying answer.
  17. >
  18. >I couldn't quite figure out how to do this. Below is the pseudo-code :
  19. >
  20. >void do_something(void)
  21. >{
  22. >}
  23. >
  24. >void call_this(void func)
  25. >{
  26. >   func();
  27. >}
  28. >
  29. >main()
  30. >{
  31. >  void (*fp)() = do_something();
  32. s/b: "  "  "  " = do_something;
  33. >  call_this(fp);
  34. >}
  35. >
  36. >Okay, I am quite sure that I got the main() part right. But I'm not
  37. >sure how
  38.  Also should change the definition of 'call_this' to take a
  39. function-ptr and invoke the function indirectly through it.
  40.  
  41.